<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('在线管理列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>账号：</label>
                                <input type="text" name="username"/>
                            </li>
                            <li>
                                <label>姓名：</label>
                                <input type="text" name="realname"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="radius:order:remove">
                    <i class="fa fa-remove"></i> 强制下线
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('radius:online:edit')}]];
        var removeFlag = [[${@permission.hasPermi('radius:online:remove')}]];
        var prefix = ctx + "radius/online";

        $(function() {
            var options = {
                url: prefix + "/list",
                removeUrl: prefix + "/remove",
                modalName: "在线管理",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'acctSessionId',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'username',
                    title: '账号'
                },
                {
                    field: 'realname',
                    title: '姓名'
                },
                {
                    field: 'nasId',
                    title: '设备标识'
                },
                {
                    field: 'acctStartTime',
                    title: '上线时间'
                },
                {
                    field: 'nasAddr',
                    title: '设备IP'
                },
                {
                    field: 'framedIpaddr',
                    title: '用户IP'
                },
                {
                    field: 'macAddr',
                    title: '用户MAC'
                },
                {
                    field: 'nasPortId',
                    title: '端口'
                },
                {
                    field: 'acctInputTotal',
                    title: '上传',
                    formatter: function(value, row, index) {
                        return bytesToSize(row.acctInputTotal);
                    }
                },
                {
                    field: 'acctOutputTotal',
                    title: '下载',
                    formatter: function(value, row, index) {
                        return bytesToSize(row.acctOutputTotal);
                    }
                },
                {
                    field: 'acctInputPackets',
                    title: '上行数据包'
                },
                {
                    field: 'acctOutputPackets',
                    title: '下行数据包'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.acctSessionId + '\')"><i class="fa fa-remove"></i>强制下线</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function bytesToSize(bytes) {
            var sizes = ['bytes', 'K', 'M', 'G', 'T'];
            if (bytes == 0) return '0 Byte';
            var i = Number(Math.floor(Math.log(bytes) / Math.log(1024)));
            return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];
        }
    </script>
</body>
</html>